using IStrong.EC.Abstractions.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;

namespace IStrong.EC.WebApi.Results.Entity
{
    /// <summary> 
    /// 服务合同盘点表各小组年目标
    /// </summary> 
    public class MaintenancePlan2
    {
        /// <summary> 
        /// ID
        /// </summary> 
        public int Id { get; set; }

        /// <summary> 
        /// 责任区域
        /// </summary> 
        public string Territory { get; set; }

        /// <summary>
        /// 总目标
        /// </summary>
        public decimal Summation { get { return SinceSigning + AgreementSigned; } }

        /// <summary> 
        /// 自签目标
        /// </summary> 
        public decimal SinceSigning { get; set; }

        /// <summary> 
        /// 协签目标
        /// </summary> 
        public decimal AgreementSigned { get; set; }

        /// <summary> 
        /// 计划时间
        /// </summary> 
        private DateTime _PlanTime { get; set; }

        /// <summary>
        /// 计划时间
        /// </summary>
        public string PlanTime
        {
            get
            {
                if (null != _PlanTime)
                {
                    return _PlanTime.ToString("yyyy-MM-dd");
                }
                return string.Empty;
            }
            set
            {
                if (!string.IsNullOrWhiteSpace(value))
                    _PlanTime = DateTime.Parse(value);
            }
        }

        /// <summary> 
		/// 合计完成额
		/// </summary> 
		public decimal SummationDone { get { return SinceDone + AgreementDone; } }
        /// <summary> 
        /// 自签完成额
        /// </summary> 
        public decimal SinceDone { get; set; }

        /// <summary> 
        /// 协签完成额
        /// </summary> 
        public decimal AgreementDone { get; set; }

        /// <summary>
        /// 合计完成率
        /// </summary>
        public decimal SummationPercentage
        {
            get
            {
                if (SummationDone >= Summation && SummationDone > 0 && Summation > 0)
                {
                    return 100;
                }
                else if (SummationDone < Summation && SummationDone > 0)
                {
                    return Math.Round(SummationDone / Summation * 100,2);
                }
                else
                {
                    return 0;
                }
            }
        }

        /// <summary>
        /// 自签完成率
        /// </summary>
        public decimal SincePercentage
        {
            get
            {
                if (SinceDone >= SinceSigning && SinceDone > 0 && SinceSigning >0)
                {
                    return 100;
                }
                else if (SinceDone < SinceSigning && SinceDone > 0)
                {
                    return Math.Round(SinceDone / SinceSigning * 100,2);
                }
                else
                {
                    return 0;
                }
            }
        }

        /// <summary>
        /// 协签完成率
        /// </summary>
        public decimal AgreementdPercentage
        {
            get
            {
                if (AgreementDone >= AgreementSigned && SinceDone > 0 && AgreementSigned > 0)
                {
                    return 100;
                }
                else if (AgreementDone < AgreementSigned && AgreementDone > 0)
                {
                    return Math.Round(AgreementDone / AgreementSigned * 100,2);
                }
                else
                {
                    return 0;
                }
            }
        }

    }
}

